package com.sfzd5.whiteboard;

import javax.swing.*;
import java.awt.*;

public class WhiteBoard {
    public JPanel mPanel;
    private JPanel controlerPanel;
    private JPanel pPanel;

    PaintCanvas drawPanel;
    ColorPanel colorPanel;
    PencileStroke pencileStroke;

    public WhiteBoard() {

        drawPanel = new PaintCanvas();
        pPanel.add(drawPanel);

        colorPanel = new ColorPanel(drawPanel);
        controlerPanel.add(colorPanel);

        pencileStroke = new PencileStroke(drawPanel);
        controlerPanel.add(pencileStroke);

    }

    public void setBackgroundImage(Image image) {
        drawPanel.setBackgroundImage(image);
    }

    public void clear() {
        drawPanel.clear();
    }

    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        mPanel = new JPanel();
        mPanel.setLayout(new BorderLayout(0, 0));
        controlerPanel = new JPanel();
        controlerPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        mPanel.add(controlerPanel, BorderLayout.SOUTH);
        pPanel = new JPanel();
        pPanel.setLayout(new BorderLayout(0, 0));
        mPanel.add(pPanel, BorderLayout.CENTER);
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() {
        return mPanel;
    }
}
